<?php

namespace App\SDK\PingAn\library;

class Config
{
    private static $_instance;
    private $_config;

    private static function instance()
    {
        if (self::$_instance == null) {
            self::$_instance = new self();
        }
        return self::$_instance;
    }

    public static function get($key = '') {
        $config = self::instance()->config();
        if ($key == '') {
            return $config;
        }
        return $config[$key] ?? null;
    }

    private function config() {
        if (is_null($this->_config)) {
            $this->_config = require(__DIR__ . '/../config/config.php');
        }
        return $this->_config;
    }
}
